package main

import "fmt"
import (
	"math/rand"
	"time"
	"math"
	"sort"
)

func indexOfBiggest(nums []int, mynum int) int{
	i := 0;
	for _, num := range nums {
		if num > mynum{
			//fmt.Println(num)
			i += 1
		}
	}
	return i
}
func sum(nums []int) int {
	//fmt.Print(nums, " ")
	total := 0
	for _, num := range nums {
		total += num
	}
	//fmt.Println(total)
	return total
}
func mySqure(a int) int{
	return a*a
}
func mySqrt(a int) int{
	return int(math.Sqrt(float64(a)))
}
func getMax(arr []int) (int) {
	newArr := make([]int,len(arr))
	for i := 0;i<len(newArr);i++{
		newArr[i] = mySqure(arr[i])%sum(arr)
	}

	max2,i2 := -1,-1
	for i:=0;i<len(newArr);i++{
		if max2 < newArr[i]{
			i2 = i
			max2 = newArr[i]
		}
	}
	return indexOfBiggest(arr,arr[i2])
}
func forge(arr []int){
	for i:=1000000;i<2000000;i++{

		arr = append(arr, i)

	}
}
func main() {
	const testLen = 20//r.Intn(10)+5
	res := make([]int, testLen)
	for j:=0;j<100000;j++{
		arr:=[]int{}
		r := rand.New(rand.NewSource(time.Now().UnixNano()))

		for i:=0;i<testLen;i++{
			arr = append(arr, 1000000 + r.Intn(1000000))
		}
		sort.Ints(arr)
		i1:=getMax(arr)
		res[i1] += 1
	}
	fmt.Println(res)

}
